//
// Created by liule on 2021/8/13.
//

#ifndef TANCHISHE_GameWidget_H
#define TANCHISHE_GameWidget_H

#include <QWidget>
#include <QPointer>
#include <QPaintEvent>
#include <QTimer>

#include "Wall.h"
#include "Snake.h"
#include "Food.h"

class GameWidget :public QWidget {
    Q_OBJECT

private:
    bool isStart; //默认游戏关闭
    int curKey; //默认按键值

    QTimer *timer;

    Wall *wall;
    Snake *snake;
    Food *food;

public:
    const int default_multiple = 15;

    GameWidget(QWidget *parent = nullptr);
    ~GameWidget();

    void paintEvent(QPaintEvent *);
    void keyPressEvent(QKeyEvent*);

    void startGame();
    void stopGame();

    void initGame();
    void destoryGame();

private slots:
    void refreshGame();

};


#endif //TANCHISHE_GameWidget_H
